<?php

if ( $_SESSION['logged_in'] == FALSE ) redirect (base_url ());

/*
 * Modify a property
 * called from users/propertyedit
 * 
 */
echo '<div id="contentfull">';
echo '<div id="forms">';
$pid = $property['pid'];
echo '<a href="'.$baseurl.'index.php/listprop"><img class="btnimg" src="'.$baseurl.'public/images/close.png" align="right" alt="close" title="Close" border="0" /></a>';
$hidden = array('pid' => $pid );
$opt = array('name' => 'editprop', 'id' => 'editprop');

echo form_open($baseurl.'index.php/propertyedit/'.$pid, $opt, $hidden);
echo form_fieldset('<h2>   Modify Property   </h2>');

?>
 
<table>
    <tr>
        <td width="150px" >
<?php   echo form_label('Property Name *', 'pname'); 
        //echo form_error('Name'); 
        $namec = array('name' => 'pname', 
               'id' => 'pname',  
               'maxlength'   => '50',
               'value'       => $property['Name'],
              'style'       => 'width: 200px' ); ?>  </td>
        <td width="200px" ><?php echo form_input($namec); echo '<br>'.form_error('pname');?>       </td>
        <td width="150px" ><?php echo form_label('Property ID' ); ?> </td>
        <td width="200px" > <?php echo $pid; ?></td>
    </tr>
   
    <tr>
        <td> <?php echo form_label('Street *', 'Street');  
        $StreetOpt = "name='Street' id='Street' ";
        $options = [];
        $options = array_merge($options, array('0' => 'Please select '));
        foreach($streets as $value)
          {
            $mid = $value['Street'] ;
            $t = array($mid => $value['Street']);
            $options = array_merge($options, $t); 
          }     
?> </td>
        <td> <?php 
            echo form_dropdown('Street', $options, $property['street']); 
            echo '<br>'.form_error('Street');
            ?> 
        </td>
        <td> <?php echo form_label('Street Number *', 'roadnum'); $rdnumopt = array('name' => 'roadnum', 
               'id' => 'roadnum',  
              'value'       => $property['roadnum'],
              'style'       => 'width: 80px'); ?>
    </td>
        <td> <?php 
            echo form_input($rdnumopt);
            echo '<br>'.form_error('roadnum'); ?> </td>
    </tr>
    
    <tr>
        <td> <?php echo form_label('Nearest Intersection *', 'intersect'); $intersectc = array('name' => 'intersect', 
               'id' => 'intersect',  
               'maxlength'   => '200',
              'value'       => $property['intersect'],
              'style'       => 'width: 200px' ); ?> </td>
        <td> <?php 
            echo form_input($intersectc); 
            echo '<br>'.form_error('intersect'); 
            ?> 
        </td>
        
        <td> <?php echo form_label('GPS Longitude', 'longitude');  
            $gpslongc = array('name' => 'longitude', 
               'id' => 'longitude',  
               'maxlength'   => '10',
               'value'       => $property['gps']['longitude'],
               'style'       => 'width: 80px'); ?>
        <td> <?php 
            echo form_input($gpslongc); 
            echo '<br>'.form_error('longitude'); 
            ?> 
        </td>
        
        <td> <?php echo form_label('GPS Latitude', 'latutude');
                $gpslatc = array('name' => 'latutude', 
               'id' => 'latutude',  
               'maxlength'   => '10',
               'value'       => $property['gps']['latutude'],
               'style'       => 'width: 80px');   ?>
        </td>
        <td> <?php 
            echo form_input($gpslatc); 
            echo '<br>'.form_error('latutude'); ?> </td>
   </tr>
   <tr>
        <td> <?php echo form_label('Owner', 'oid');  $OwnerOpt = " 'name'='oid' 'id'='oid' " ;
         $options = [];
         $options = array_merge( $options, array('null' => 'Please select') );
         foreach($owners as $value)
          {
            $mid = $value['id'] ;
            $t = array($mid => $value['Name']);
            $options = array_merge($options, $t); 
          }
         $selected = $property['Owner']['oid'];
?>   </td>
     <td> <?php 
         echo form_dropdown('oid', $options, $selected); 
         ?> 
     </td>
   <tr>
     <td colspan="4" align="right" > <?php echo form_submit('save', 'Save'); echo form_reset('reset', 'Reset');?>  
   </tr>
</table>    
<?=form_fieldset_close()?>
<?=form_close(); ?>

</div> <!--content-->
</div> <!--login-->
